<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Searching</title>
</head>
<%
	try {
		if (request.getSession().getAttribute("userId")!= null)
			response.sendRedirect("AccessDenied.jsp");
	} catch (Exception e) {
		response.sendRedirect("AccessDenied.jsp");
	}
%>
<body style="background-color: #94C0D6">
	<img alt="" src="Swim.jpg" style="height: 64px; width: 200px;">
	<br><br>
	<form
		style="background-color: #A6B0DB; border-bottom-width: thin; border-right-width: thin; border-left-width: thin; border-top-width: thin; border-top-color: #8080FF; border-right-color: #8080FF; border-top-style: solid; border-right-style: solid; height: 24px;">
		<a href="LogOutServlet">Exit</a>
	</form>
	<center>
		<form style="width: 218px; background-color: #8080FF; height: 22px; vertical-align: middle; border-top-style: solid; border-top-color: #8080C0; border-right-color: #8080C0; border-right-width: thin; border-right-style: solid; border-top-width: thin">
			<center>
				<b>SEARCHING SYSTEM</b>
			</center>
		</form>
	</center>

	<form action="UnregisteredSearchServlet">
	<br><br><br>
		<table border="0" cellspacing="0" cellpadding="5" align="center" style="background-color: #8080C0; border-top-style: solid; border-top-color: #8080C0; border-right-color: #8080C0; border-right-style: none; border-left-width: thin; border-bottom-color: #8080C0; border-top-width: thin; border-left-style: solid">
			<thead style="width: 595px; ">
				<tr>
					<th>Choose Ability</th>
				</tr>
			</thead>
			<tr>
				<td style="width: 173px;"><select name="ability" id="Select1"
					size='
    <%ArrayList<String> abilityList = (ArrayList<String>) request.getSession().getAttribute("abilities");
			if (abilityList != null) {
				int length = abilityList.size();
				out.print(length);
			} else {
				out.print(0);
			}%>'
					multiple="multiple" style="height: 78px; width: 161px">
						<%
							int i = 0;
							if (abilityList != null) {
								for (String ability : abilityList) {
									out.println("<option name = \"value\" value=\"" + ability
											+ "\">" + ability + "</option>");
									i++;
								}
							}
						%>
				</select></td>
				<td><input type="submit" value="Search" style="background-color: #8080FF;"></td>
			</tr>
		</table>
		</center>
	</form>
	<%@page import="java.util.*"%>
	<%@page import="entities.*"%>
	<%
		List<RegisteredUser> results = (List<RegisteredUser>) request.getSession().getAttribute("result");
		%>
		<center><form style="background-color: #A6B0DB; width: 340px">
		<%
		if (results == null)
			out.print("<center> Perform a new search </center>");
		else {
			for (RegisteredUser user : results)
				out.println("<br> <center><a href=\"UnregisteredProfileServlet?user="
						+ user.getUserId() + "\">" + user.getSurname()
						+ " " + user.getName() + "</a><br></center>");
		}
		request.getSession().removeAttribute("result");
	%>
	</form>
	</center>
</body>
</html>